<?PHP

session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
    header("Location: login.php");
}
//
include 'i_functions.php';
include 'i_ImportDataInit.php';
include 'i_Map2Table.php';
//
$uname = "";
$pword = "";
$errorMessage = "";
$num_rows = 0;
$used = "";
//
$user_name = "root";
$pass_word = "haddons";
$database = "PPI";
$server = "127.0.0.1";
//
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
//
if ($db_found) {
    $Columns = array("TABLE_NAME");
    $Options = array();
    $Options["Id"] = "Table";
    $Options["Name"] = "Table";
    $Options["Filter"] = "TABLE_SCHEMA = 'PPI'";
    $TableSelect = SelectList("INFORMATION_SCHEMA.TABLES", $Columns, $Options);
    //print $TableSelect . "<br>";
} else {
    $errorMessage = "Database Not Found";
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//
    $csvFile = "data/" . $_POST["csvFile"];
    $TableName = $_POST["Table"];
    $Options = array();
    $Options["Chooser"] = 2;
//
    $HTML = Map2Table($csvFile, $TableName, 1, $Options);
//
    include 'i_head.php';
    print $HTML;
    include 'i_foot.html';
//
} else {
    include 'i_head.php';
    include 'i_ImportMapForm.php';
    include 'i_foot.html';
}
?>


